<?php

include '../database/koneksi/Koneksi.php';

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Tampil
 *
 * @author BAGUS
 */
class Tampil {

    //put your code here
    public function tampilProvinsi() {
        $koneksi = new Koneksi();
        $koneksi->koneksiDB();
        $rs = mysql_query("select * from provinsi where id_provinsi != '00'");
        if (!$rs) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        $arrayData = null;
        $i = 0;
        while ($row = mysql_fetch_array($rs)) {
            $arrayData[$i++] = $row["nama_provinsi"];
        }
        return $arrayData;
    }

    public function tampilIdProvinsi() {
        $koneksi = new Koneksi();
        $koneksi->koneksiDB();
        $rs = mysql_query("select * from provinsi where id_provinsi != '00'");
        if (!$rs) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        $arrayData = null;
        $i = 0;
        while ($row = mysql_fetch_array($rs)) {
            $arrayData[$i++] = $row["id_provinsi"];
        }
        return $arrayData;
    }


//    public function tampilProvinsi1($id_prov) {
//        $koneksi = new Koneksi();
//        $koneksi->koneksiDB();
//        $rs = mysql_query("select * from propinsi_pemberi where id_propinsi_pemberi='$id_prov'");
//        if (!$rs) {
//            echo 'Could not run query: ' . mysql_error();
//            exit;
//        }
//        $arrayData = null;
//        $i = 0;
//        while ($row = mysql_fetch_array($rs)) {
//           $arrayData[$i++] = $row["nama_propinsi_pemberi"];
//        }
//        return $arrayData;
//    }
//    public function tampilKabupaten1($id_prov) {
//        $koneksi = new Koneksi();
//        $koneksi->koneksiDB();
//        $rs = mysql_query("select * from kabupaten_pemberi where id_propinsi_pemberi='$id_prov'");
//        if (!$rs) {
//            echo 'Could not run query: ' . mysql_error();
//            exit;
//        }
//        $arrayData = null;
//        $i = 0;
//        while ($row = mysql_fetch_array($rs)) {
//           $arrayData[$i++] = $row["nama_kabupaten_pemberi"];
//        }
//        return $arrayData;
//    }

    public function tampilKabupaten($id_provinsi) {
        $arrayData = null;
        $koneksi = new Koneksi();
        $koneksi->koneksiDB();
        //ambil nama_kabupaten
        $rs = mysql_query("select * from kabupaten where id_kabupaten != '00' and id_provinsi = '" . mysql_real_escape_string($id_provinsi) . "'");
        if (!$rs) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        $i = 0;
        while ($row = mysql_fetch_array($rs)) {
            $arrayData[$i++] = $row["nama_kabupaten"];
        }


        return $arrayData;
    }

    public function tampilIdKabupaten($id_provinsi) {
        $arrayData = null;
        $koneksi = new Koneksi();
        $koneksi->koneksiDB();
        //ambil nama_kabupaten
        $rs = mysql_query("select * from kabupaten where id_kabupaten != '00' and id_provinsi = '" . mysql_real_escape_string($id_provinsi) . "'");
        if (!$rs) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        $i = 0;
        while ($row = mysql_fetch_array($rs)) {
            $arrayData[$i++] = $row["id_kabupaten"];
        }


        return $arrayData;
    }

    public function tampilKategori() {
        $koneksi = new Koneksi();
        $koneksi->koneksiDB();
        $rs = mysql_query("select * from kategori");
        if (!$rs) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        $arrayData = null;
        $i = 0;
        while ($row = mysql_fetch_array($rs)) {
            $arrayData[$i++] = $row["nama_kategori"];
        }
        return $arrayData;
    }

    public function tampilIDKategori() {
        $koneksi = new Koneksi();
        $koneksi->koneksiDB();
        $rs = mysql_query("select * from kategori");
        if (!$rs) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        $arrayData = null;
        $i = 0;
        while ($row = mysql_fetch_array($rs)) {
            $arrayData[$i++] = $row["id_kategori"];
        }


        return $arrayData;
    }

    public function tampilID_Pemberi($email) {
        $id = "";
        $koneksi = new Koneksi();
        $koneksi->koneksiDB();
        $rs = mysql_query("select * from pemberi where email_pemberi = '$email'");
        if (!$rs) {
            echo 'Could not run query: ' . mysql_error();
            exit;
        }
        while ($row = mysql_fetch_array($rs)) {
            $id = $row["id_pemberi"];
        }

        return

                $id;
    }

    var $kab;

    public function getKab() {


        return $this->kab;
    }

    public function setKab($kab) {
        $this->kab = $kab;
    }

}
